﻿@model SportStore.Models.ProductViewModel
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<h2>
    @if(Model.ProductId!=0) {
        <span>Edit</span>
    } else {
        <span>Create</span>
    }
    @Model.Name</h2>
        
@using (Html.BeginForm("Edit", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.HiddenFor(m=>m.ProductId)    <div class="editor-label">@Html.LabelFor(m=>m.Name) </div>
<div class="editor-field">@Html.EditorFor(m=>m.Name) </div>
<div class="editor-label">@Html.LabelFor(m => m.Description) </div>
<div class="editor-field">@Html.EditorFor(m => m.Description) </div>
<div class="editor-label">@Html.LabelFor(m => m.Price)</div>
<div class="editor-field">@Html.EditorFor(m => m.Price)</div>
    <div class="editor-label">
        Category</div>
    <div class="editor-field">
        @Html.DropDownListFor(m => m.CategoryId, new SelectList(ViewBag.PossibleCategories, "CategoryID", "Name", Model.CategoryId))
        @Html.ValidationMessageFor(m => m.CategoryId)
    </div>
    <div class="editor-label">
        Image</div>
    <div class="editor-field">
        @if (Model.ImageFileName == null)
        {
            @:None
        }
        else
        {
            <img width="auto" height="150" alt="" src="@Model.ImageFileName" />
        }
        <div>
            Upload new image:
            <input type="file" name="Image" /></div>
    </div>
    <input type="submit" value="Save" />
    @Html.ActionLink("Cancel and return to List", "Index")
}